package com.barunsw.bwf.ems.neoarena.slot;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.ems.common.controller.CommonController;
import com.barunsw.bwf.ems.neoarena.model.Slot;

@Controller
@RequestMapping("/node")
public class SlotController extends CommonController {
	private static final Logger LOGGER = LoggerFactory.getLogger(SlotController.class);
	
	@Autowired
	SlotService slotService;
	
	/**
	 * Slot 리스트 조회
	 * 
	 * @param nodeId 조회하고자 하는 Node
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/{nodeId}/slot", method = RequestMethod.GET)
	public @ResponseBody List<Slot> getSlotList(@RequestBody @PathVariable long nodeId) throws Exception {
		return slotService.getSlotList(nodeId);
	}

	/**
	 * Slot 정보 조회
	 * 
	 * @param nodeId 조회하고자 하는 Node
	 * @param slotId 조회하고자 하는 Slot
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/{nodeId}/slot/{slotId}", method = RequestMethod.GET)
	public @ResponseBody Slot getSlot(@RequestBody @PathVariable long nodeId, @PathVariable int slotId) throws Exception {
		return slotService.getSlot(nodeId, slotId);
	}
}